﻿/*
 * 版权所有 2024 Rapid Software LLC
 * 
 * 根据 Apache 许可证 2.0 版（“许可证”）获得许可;
 * 除非符合许可，否则您不得使用此文件.
 * 您可以在以下位置获取许可证的副本
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 * 
 * Product  : Rapid SCADA
 * Module   : ScadaCommCommon
 * Summary  : Represents a device tag
 * 
 * Author   : Mikhail Shiryaev
 * Created  : 2020
 * Modified : 2020
 */

using System.Collections.Generic;

namespace Scada.Comm.Devices
{
    /// <summary>
    /// Represents a group of device tags.
    /// 表示一组设备标记
    /// <para>Представляет группу тегов устройства.</para>
    /// </summary>
    public class TagGroup
    {
        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        public TagGroup()
            : this("")
        {
        }

        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        public TagGroup(string name)
        {
            Name = name;
            Hidden = false;
            DeviceTags = new List<DeviceTag>();
        }


        /// <summary>
        /// Gets or sets the group name.
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether the group appears in the device information.
        /// </summary>
        public bool Hidden { get; set; }

        /// <summary>
        /// Gets the device tags.
        /// </summary>
        public List<DeviceTag> DeviceTags { get; }


        /// <summary>
        /// Adds a new tag to the group.
        /// </summary>
        public DeviceTag AddTag(string code, string name)
        {
            DeviceTag deviceTag = new DeviceTag(code, name);
            DeviceTags.Add(deviceTag);
            return deviceTag;
        }
    }
}
